﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ModelTitle : MonoBehaviour {

    public GameObject Target;
    public float OffsetX;
    public float OffsetY = 1;
    public float OffsetZ;
    private Text _text;
    public Text Text {
        get {
            if (this._text == null) {
                this._text = this.GetComponent<Text>();
            }
            return this._text;
        }
    }

    private Vector3 Offset;

    // Use this for initialization
    void Start() {
        this.Offset = new Vector3(this.OffsetX, this.OffsetY, this.OffsetZ);
    }

    // Update is called once per frame
    void Update() {
        //Follow();
    }

    private void LateUpdate() {
        Follow();
    }

    private void Follow() {
        transform.position = Target.transform.position + this.Offset;
        transform.position = Camera.main.WorldToScreenPoint(this.Target.transform.position + this.Offset);
    }

}
